<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  
</body>
<script>


  var res = setTimeout(function(){
    console.log("hello world")
  }, 5000);
  
  document.onclick = function(){
    clearTimeout( res );
  }
  
</script>
</html>